package com.zhangchuchu.neohealth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhangchuchu.neohealth.entity.VisitLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface VisitLogMapper extends BaseMapper<VisitLog> {
    @Select("SELECT DATE(visit_time) AS day, COUNT(*) AS count " +
            "FROM visit_log " +
            "WHERE DATE(visit_time) >= DATE(#{start}) AND DATE(visit_time) <= DATE(#{end}) " +
            "GROUP BY DATE(visit_time)" +
            "ORDER BY day ASC")
    List<Map<String, Object>> getVisitStats(@Param("start") LocalDateTime start,
                                            @Param("end") LocalDateTime end);
}
